angular.module('feedback.controller', [])
  .controller('feedbackCtrl', ['$scope', '$timeout', '$localstorage', '$ionicPopup', 'feedbackService', '$state', 'loginService', '$ionicHistory', function ($scope, $timeout, $localstorage, $ionicPopup, feedbackService, $state, loginService, $ionicHistory) {

    $scope.params={}; 
    $scope.params = feedbackService.getParams(); 
    $scope.$on('$ionicView.enter', function(event, data) { 
    });
    $scope.submitfeedback = function () {
        $scope.params.Depart_Code = $localstorage.get("Depart_Code");
        $scope.params.User_ID = $localstorage.get("User_ID");
        $scope.params.Phone = $localstorage.get("Phone");
        $scope.params['Remark'] = $('#remark').val();
        if ($scope.params['Remark'] == null || $scope.params['Remark'] == '') {
            var alertPopup = $ionicPopup.alert({
                title: '提示！',
                template: "请输入您的建议！",
                okText: '确定',
                okType: 'item-customer-bg-darkred',
            });
        }
        else {
            feedbackService.get_submitfeedback($scope.params).then(function (data) {
                var alertPopup = $ionicPopup.alert({
                    title: '提示！',
                    template: "谢谢您提出的珍贵建议！",
                    okText: '确定',
                    okType: 'item-customer-bg-darkred',
                });
            }, function (error) {
                var alertPopup = $ionicPopup.alert({
                    title: '提示！',
                    template: "提交失败！" + error,
                    okText: '确定',
                    okType: 'item-customer-bg-darkred',
                });
            });
        }
    };
    $scope.goBack = function(){
      $ionicHistory.goBack(-1);//back到之前的路由
    }
  }]);
